package Thread;

import java.util.Scanner;

public class Demo6 {

    public static void main(String[] args) {

        Object locker = new Object();

       Thread t1 = new Thread(()-> {
           synchronized (locker) {
               System.out.println("t1等待之前");
               try {
                   locker.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               System.out.println("t1等待之后");
           }
       });

       Thread t2 = new Thread(()-> {
           synchronized (locker) {
               System.out.println("t2等待之前");
               Scanner scanner = new Scanner(System.in);
               scanner.next();

               locker.notify();
               System.out.println("t2等待之后");

           }

       });

       t1.start();
       t2.start();
    }
}
